<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/jquery-3.4.1.min.js"></script>
    <style>
        #d{
            height: 100px;
            width: 100px;
            background: red;
        }
        #d1{
            height: 100px;
            width: 100px;
            background: blue;
        }
    </style>
</head>

<body>
    <!-- 绑定事件和解除绑定事件
    动态的给jQuery对象绑定一个或者多个事件
     主要给未来通过js添加的元素绑定事件 -->
    <div id="d">12313131</div>
    <div id="d1"></div>
    <button>解除绑定</button>
    <script>
        $(function () {
            // 绑定多个
            $('div').bind('mouseover', function () {
                $('div').css('background', 'black')
            }).bind('mouseout', function () {
                $('div').css('background', 'red')
            })

            
            $('button').click(function(){
                $('div').unbind('mouseover');
            })
// ----------------------------------------------------------------------------

            $('div').bind('mouseover', bg=function () {
                $('div').css('background', 'black')
            }).bind('mouseover', c=function () {
                $('div').css('color', 'red')
            })


            $('button').click(function(){
                $('div').unbind('mouseover',c);
            })
        })

    </script>
</body>

</html>